package com.geline.sqlbackup.util;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author: mengxin
 * @date: 2022/7/11 22:36
 */
public class SqlBuilderUtilTest {

    public static void main(String[] args) {
        Map<String, Object> bean = new HashMap<>();
        bean.put("id", 123);
        bean.put("userName", "zs");
        bean.put("birthDay", "2020-10-10");
        bean.put("createTime", new Date());

        String selectByIdSql = SqlBuilderUtil.getSelectByIdSql("t_user", "1000");
        //SELECT * FROM t_user WHERE id = ?
        System.out.println(selectByIdSql);

        String insertSql = SqlBuilderUtil.getInsertSql("t_user", bean);
        //INSERT INTO t_user (birthDay, createTime, id, userName) VALUES (?, ?, ?, ?)
        System.out.println(insertSql);

        String updateSql = SqlBuilderUtil.getUpdateByIdSql("t_user", bean);
        //UPDATE t_user SET birthDay = ? , createTime = ? , userName = ?  WHERE id = ?
        System.out.println(updateSql);

        String deleteByIdSql = SqlBuilderUtil.getDeleteByIdSql("t_user", "120");
        //DELETE FROM t_user WHERE id = ?
        System.out.println(deleteByIdSql);

        String deleteByIdsSql = SqlBuilderUtil.getDeleteByIdsSql("t_user", "120", "102");
        //DELETE FROM t_userid IN (120,102,100)
        System.out.println(deleteByIdsSql);
    }
}
